package com.mallcai.bigdata.ladon.dpl.mapper.peekdata;

import com.mallcai.bigdata.ladon.dpl.entity.peekdata.PeekRule;
import com.mallcai.bigdata.ladon.dpl.mapper.peekdata.provider.PeekRuleSqlProvider;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author gst
 * @date 2019-12-30 20:36
 */
@Repository
public interface PeekRuleMapper {

    @InsertProvider(type = PeekRuleSqlProvider.class, method = "insert")
    int insert(PeekRule peekRule);

    @InsertProvider(type = PeekRuleSqlProvider.class, method = "update")
    int update(PeekRule peekRule);

    @Delete({
            "DELETE FROM " + PeekRuleSqlProvider.TB_PEEK_RULE + " where id = #{id}"
    })
    int delete(PeekRule peekRule);

    @SelectProvider(type = PeekRuleSqlProvider.class, method = "getByPeekId")
    List<PeekRule> getByPeekId(@Param("peekId") Long peekId);

    @Delete({
            "DELETE FROM " + PeekRuleSqlProvider.TB_PEEK_RULE + " WHERE peek_id = #{peekId}"
    })
    int delByPeekId(@Param("peekId") Long peekId);

    @Delete({
            "DELETE FROM " + PeekRuleSqlProvider.TB_PEEK_RULE + " WHERE id = #{id}"
    })
    int deleteById(@Param("id") Long id);
}
